/**
 * @param {number[][]} intervals
 * @return {number}
 * 返回 需要移除区间的最小数量，使剩余区间互不重叠
 * 类似安排会议,计算出最大不重叠区间数，用总长减去不重叠数就是要移除的
 */
var eraseOverlapIntervals = function (intervals) {
    intervals.sort((a, b) => {
        return a[1] - b[1]
    })
    let count = 1,
        curr = intervals[0]
    for (let i = 1; i < intervals.length; i++) {
        if (intervals[i][0] >= curr[1]) {
            count++
            curr = intervals[i]
        } else {
            continue
        }
    }
    return intervals.length - count
};